<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>
			child -
			https://developer.mozilla.org/zh-CN/docs/Web/API/Window/postMessage
		</title>
	</head>

	<body>
		<div>
			<input type="button" value="点击发送给父亲" id="btn" />
		</div>

		<script>
			const btn = document.querySelector('#btn')
			btn.addEventListener('click', (e) => {
				window.parent.postMessage('child-to-Parent', '*')
			})

			window.addEventListener('message', (e) => {
				console.log('origin', e.origin)
				console.log('get Message', e.data)
			})
		</script>
	</body>
</html>
